<!DOCTYPE html>
<html lang="zh">

<head>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>页面</title>
    <script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/loading.js"></script>
    <link href="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/lib/theme-chalk/index.css" rel="stylesheet">
</head>

<body>
<div id="app">
    <el-container v-loading="loading">
        <el-header>
            <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item :to="{ path: '/' }">合作商管理</el-breadcrumb-item>
                <el-breadcrumb-item>价目表列表</el-breadcrumb-item>
                <el-breadcrumb-item>价目表变更信息查看</el-breadcrumb-item>
            </el-breadcrumb>
        </el-header>
        <el-main>
            <el-form label-width="120px">
                <el-row>
                    <el-col>
                        <el-steps :active="1" simple>
                            <el-step title="基本信息" icon="el-icon-info" style="margin-left:-8%"></el-step>
                        </el-steps>
                    </el-col>
                </el-row>
                <br>
                <el-row>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="价目表编号" prop>
                            <el-input v-model="tariffModify.priceCode" disabled></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="价目表名称" >
                            <el-input v-model="tariffModify.priceName" disabled></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="价目表增补编号" prop>
                            <el-input v-model="tariffModify.chgSmycode" disabled></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="价目表增补名称" >
                            <el-input v-model="tariffModify.chgSmyName" disabled></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="变更日期" prop>
                            <el-input v-model="tariffModify.crtTime" disabled></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="生效日期" >
                            <el-input v-model="tariffModify.efvTime" disabled></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
                        <el-form-item label="备注" prop>
                            <el-input v-model="tariffModify.remark" type="textarea" disabled></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col>
                        <el-steps :active="1" simple>
                            <el-step title="SKU清单" icon="el-icon-info" style="margin-left:-8%"></el-step>
                        </el-steps>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :xs="12" :sm="12" :md="8" :lg="8" :xl="8">
                        <el-input placeholder="请输入内容" @keyup.enter.native="enterSearch" v-model="keySearch">
                            <el-button slot="append" icon="el-icon-search" @click=search></el-button>
                        </el-input>
                    </el-col>
                </el-row>
                <el-table v-loading="tableLoading" :data="tableData"
                          class="tb-edit" style="width: 100%" highlight-current-row
                          size="mini" tooltip-effect="dark" border height="calc(100vh - 428px)">
                    <el-table-column label="序号"
                                     width="50">
                        <template scope="scope"><span>{{scope.$index+(currentPage - 1) * pageSize + 1}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column label="状态" prop="opr" :show-overflow-tooltip=true :formatter="formatStatus">
                    </el-table-column>
                    <el-table-column label="材料编码" prop="sku_code" :show-overflow-tooltip=true>
                    </el-table-column>
                    <el-table-column label="材料名称" prop="sku_name" :show-overflow-tooltip=true>
                    </el-table-column>
                    <el-table-column label="品牌" prop="sku_brand" :show-overflow-tooltip=true>
                    </el-table-column>
                    <el-table-column label="单位" prop="sku_unit" :show-overflow-tooltip=true>
                    </el-table-column>
                    <el-table-column label="规格参数" prop="sku_slug_set" :show-overflow-tooltip=true>
                    </el-table-column>
                    <el-table-column label="型号" prop="sku_model" :show-overflow-tooltip=true>
                    </el-table-column>
                    <el-table-column label="销售价格" prop="sku_contract_price" :show-overflow-tooltip=true>
                    </el-table-column>
                    <el-table-column label="变更原因" prop="reason" :show-overflow-tooltip=true>
                    </el-table-column>
                </el-table>
                <el-row>
                    <el-col>
                        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                                       :page-sizes="[100, 500, 1000]"
                                       :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper"
                                       :total="totalRecords">
                        </el-pagination>
                    </el-col>
                </el-row>
                <br>

                <el-row>
                    <a href="/tariffModifyController/list.page">
                        <el-button>返回</el-button>
                    </a>
                </el-row>
            </el-form>
        </el-main>
    </el-container>
</div>

<script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/dist/vue.js"></script>
<script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/lib/index.js"></script>
<script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/publiccss/assets/global/plugins/jquery.min.js"
        type="text/javascript"></script>
<script>
    new Vue({
        el: '#app',
        data() {
            return {
                tableLoading: false,
                loading: false,
                tableData: [],
                currentPage: 1, //当前页
                pageSize: 100, //每页总数
                totalRecords: 0, //总条数
                keySearch: '',
                tariffModify: {
                    id: '',
                    priceCode: '',
                    priceName: '',
                    chgSmycode: '',
                    chgSmyName: '',
                    remark: '',
                    crtTime: '',
                    efvTime: '',
                }
            }
        },
        methods: {
            //状态转换
            formatStatus: function (row, column) {
                return row.opr == "00" ? '新上架' : row.opr == "01" ? '已下架' : row.opr == "02" ? '已更新' : '未知';
            },
            //回车监听事件获取输入内容
            enterSearch(event) {
                this.currentPage = 1;
                this.pageSize = 100;
                this.keySearch = event.target.value;
                this.skuInfoList();
            },
            //点击事件获取输入内容
            search() {
                this.currentPage = 1;
                this.pageSize = 100;
                this.skuInfoList();
            },
            handleSizeChange(val) {
                this.pageSize = val;
                this.skuInfoList();
            },
            handleCurrentChange(val) {
                this.currentPage = val;
                this.skuInfoList();
            },
            ajaxFunction() {
                $.ajax({
                    url: '/tariffModifyController/tablePriceChgSmyDtl.json?id=' + this.tariffModify.id,
                    type: 'get',
                    dataType: 'json',
                    success: (result) => {
                        if (result.ret) {
                            this.tariffModify = result.data;
                            this.skuInfoList();
                        } else {
                            this.$message.error('请求异常');
                        }
                    }
                });
            },
            skuInfoList() {
                this.tableLoading = true;
                $.ajax({
                    url: '/tariffModifyController/tablePriceChgList.json',
                    type: 'get',
                    data: {
                        smy_id: this.tariffModify.id,
                        key: this.keySearch,
                        page: this.currentPage,
                        limit: this.pageSize,
                    },
                    dataType: 'json',
                    success: (result) => {
                        this.tableLoading = false;
                        if (result.ret) {
                            this.tableData = result.data;
                            this.totalRecords = result.count;
                        } else {
                            this.$message.error('请求失败，请稍后重试');
                        }
                    }
                });
            },
        },
        mounted() {
            this.tariffModify.id = '${id}';
            this.ajaxFunction();
        },
    })
</script>

</body>

</html>